package com.huike.pmps.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huike.pmps.dao.ProvincesDao;
import com.huike.pmps.model.entity.Provinces;
import com.huike.pmps.model.vo.Result;
import com.huike.pmps.service.ProvincesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 作者：谌贵斌(黑桃K)
 * 日期: 2888-08-08
 * 老师QQ: 272488352
 * 官方QQ交流群: 377748272
 * 刀客程序员官网：http://www.daoke360.com
 * 刀客程序员淘宝旗舰店：https://daoke360.taobao.com/
 */
@Service
public class ProvincesServiceImpl implements ProvincesService {

    @Autowired
    ProvincesDao provincesDao;


    /**
     * 获取所有的省份数据
     *
     * @return
     */
    @Override
    public Result selectAll() {
        return Result.success(provincesDao.selectList(null));
    }

    @Override
    public Provinces selectByProvinceName(String provinceName) {
        QueryWrapper<Provinces> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("province", provinceName);
        return provincesDao.selectOne(queryWrapper);
    }

    @Override
    public Provinces selectByProvinceId(Integer provinceId) {
        QueryWrapper<Provinces> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("province_id", provinceId);
        return provincesDao.selectOne(queryWrapper);
    }
}
